import com.khh.dao.StudentDao;
import com.khh.mapper.StudentMapper;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017-09-11.
 */
public class Demo {

    @Test
    public void a(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        StudentDao sm = ctx.getBean(StudentDao.class);
        List<Map<String,Object>> list = sm.queryAll();
        System.out.println(list.size());
    }
    @Test
    public void aVe(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        StudentMapper sm = ctx.getBean(StudentMapper.class);

        int n = sm.deleteById(4);
        System.out.println(n);

    }
    @Test
    public void aV(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        StudentMapper sm = ctx.getBean(StudentMapper.class);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("name","比比");
        map.put("score",80);
        map.put("age",20);
        int n = sm.insert(map);
        System.out.println(n);
    }

    @Test
    public void aVoid(){
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        StudentMapper sm = ctx.getBean(StudentMapper.class);
        Map<String,Object> m = sm.queryById(1);
        System.out.println(m);

        List<Map<String,Object>> list = sm.queryAll();
        System.out.println(list.size());



    }
}
